﻿/*
* ==============================================================================
*
* FileName: LogHelpers.cs
* Created: 2020/6/19 14:20:10
* Author: Meiam
* Description: 
*
* ==============================================================================
*/
using System;
using System.IO;

namespace Meiam.System.Common.Helpers
{
    public class LogHelpers
    {
        public static string logWrite(string message)
        {
            return $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss:fff}] => {message}";
        }

        public static void WriteLogTXT(string logStr)
        {
            StreamWriter writer = null;
            try
            {
                string strcLogPath = @"D:\_ceshi_LOG\";//日志文件路径;//日志文件目录
                if (!Directory.Exists(strcLogPath))
                {
                    Directory.CreateDirectory(strcLogPath);
                }
                strcLogPath += DateTime.Now.Date.ToString("yyyy-M-dd") + "_test.txt";
                logStr = DateTime.Now.ToShortTimeString() + "     " + logStr;
                writer =File.AppendText(strcLogPath);
                writer.WriteLine(logStr);
                writer.WriteLine();
            }
            catch (Exception)
            {
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
            }
        }
    }
}
